using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Boom : MonoBehaviour
{
    private Animator anim;

    private void Start()
    {
        anim = GetComponent<Animator>();

        Soundmgr.Instance.PlayMusicByName("bombFall",transform.position,1.0f);
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if(other.tag == "Player")
        {
            if(other.GetComponent<Player>().GetCurState() == false)
            {
                return;
            }
            else
            {
                other.GetComponent<Player>().Hurt();
            }
        }else if(other.tag == "Ground")
        {

        }
        else
        {
            return;
        }

        GetComponent<Rigidbody2D>().gravityScale = 0f;

        GetComponent<Rigidbody2D>().velocity = new Vector2 (0f, 0f);

        anim.SetBool("Boom", true);
    }

    public void BoomDestroy()
    {
        GameObject.Destroy(gameObject);
    }

}
